Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove legacy_ibc_testing (rebased on main) #1185

Merged
merged 12 commits into from
Sep 7, 2023

Conversation

tbruyelle
Copy link
Contributor

@tbruyelle tbruyelle commented Aug 4, 2023

Description

Closes: #1008

This is a rebase of #1003 (which was on the sdk47 branch) to the main branch. It contains the same set of changes, so I chose to copy the PR body here to avoid reviewers to deal with 2 PRs.

This is also a draft PR because to be merged this requires a small change in ibc-go. But unlike the old PR, I added a replace directive in the go.mod so it uses a patched version of ibc-go, to show that the tests are passing.

If you support this change, I can make a PR on ibc-go (7.1 release branch), and once it is accepted, we can merge it.

Original PR body

As indicated in the code comments of the legacy_ibc_testing folder, this folder was meant to be removed following the IBC upgrade. In the context of the IBC v7 upgrade, I decided to tackle this task.

The process was not as straightforward as anticipated, because the legacy_ibc_testing is not merely a copy of the ibc-go/testing folder. It contains numerous adaptations related to ICS. I managed to address all of them except one, which is why some tests still fail, all for the same reason (see the valset/header update order section for details).

Here is a list of changes, categorized into three sections for easier readability: Minor changes, Consumer genesis updates, Packet sniffing, and finally, Valset/header update order.

Minor changes

  • remove legacy_ibc_testing folder, replace all imports from github.com/cosmos/interchain-security/legacy_ibc_testing to github.com/cosmos/ibc-go/v7/testing.
  • ibctesting.NewTestChain no longer accepts the appIniter. This must be assigned to ibctesting.DefaultTestingAppInit before calling NewTestChain (see documentation).
  • endpoint.SendPacket API now requires packet data and timeout values instead of a packet (see related PR).
  • ibctesting.TestingApp.GetStakingKeeper() no longer gives access to UnbondingTime() method: replace with GetTestStakingKeeper().
  • replace ibcsimapp.CreateTestPubKeys by ibctesting.GenerateKeys
  • replace icstestingutil.ReconstructPacket by ibctesting.ParsePacketFromEvents()
  • ibctesting.GetChainID() now returns by default a chainID with a revision, which wasn't expected by the tests. Disable it by setting ibctesting.ChainIDSuffix = "".

Consumer genesis updates

In consumer chains, the validator set is not expected to be find in the staking module, but rather in the consumer module. This was previously handled in SetupWithGenesisValSet, which feeds the consumer genesis with the valset passed in parameters.

With the removal of legacy_ibc_testing, it's no longer possible to adapt SetupWithGenesisValSet in this way. Therefore, I adopted a different approach. I modified the consumer and consumer-democracy appIniter to accept a valset parameter (I introduced a valSetAppIniter), and they populate their genesis from this valset (since appIniter also returns the genesis).

When calling consumer appIniter, the provider valset is passed in parameters, while when calling consumer-democracy appIniter, the valset created in the test is passed.

Similarly, SetupWithGenesisValSet expects a staking module entry in the genesis, which is not the case for a consumer chain. This was previously handled by checking if a staking entry was present in the genesis (see here). For the same reason, I had to find a workaround, and so I also updated the consumer appIniter so its genesis contains a placeholder staking entry.

Packet sniffing

The legacy_ibc_testing was adapted to record all packets in a map field of TestChain (see here). This field doesn't exist in the ibc-go/v7/testing, so I updated the CCVTestSuite struct to add a StreamingService implementation called packetSniffer to all created chains. The packetSniffer listens to EndBlock and appends all packets parsed from events.

Valset/header update order

In legacy_ibc_testing, the TestChain.NextBlock looks like that :

func (chain *TestChain) NextBlock() {
	res := chain.App.EndBlock(abci.RequestEndBlock{Height: chain.CurrentHeader.Height})

	chain.App.Commit()

	// val set changes returned from previous block get applied to the next validators
	// of this block. See tendermint spec for details.
	chain.Vals = chain.NextVals
	chain.NextVals = ApplyValSetChanges(chain.TB, chain.Vals, res.ValidatorUpdates)

	// set the last header to the current header
	// use nil trusted fields
	chain.LastHeader = chain.CurrentTMClientHeader()

In ibc-go/v7/testing, it's a little different :

func (chain *TestChain) NextBlock() {
	res := chain.App.EndBlock(abci.RequestEndBlock{Height: chain.CurrentHeader.Height})

	chain.App.Commit()

	// set the last header to the current header
	// use nil trusted fields
	chain.LastHeader = chain.CurrentTMClientHeader()

	// val set changes returned from previous block get applied to the next validators
	// of this block. See tendermint spec for details.
	chain.Vals = chain.NextVals
	chain.NextVals = ApplyValSetChanges(chain.TB, chain.Vals, res.ValidatorUpdates)

The validators are updated after the chain.LastHeader update, which makes the UpdateClient call fail, because the trusted validators hash doesn't match the consensus state next validators hash (can't give more explanations because I lack knowledge on IBC).

If we change the order like it was in legacy_ibc_testing the UpdateClient works well.

For this one I wasn't able to find a workaround, probably a PR should be submitted to ibc-go to change that order. I ran the ibc-go tests with that change and there's still green, so that looks fine. Or else maybe someone can find a workaround ?


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • Included the correct type prefix in the PR title
  • Added ! to the type prefix if state-machine breaking change (i.e., requires coordinated upgrade)
  • Confirmed this PR does not introduce changes requiring state migrations, OR migration code has been added to consumer and/or provider modules
  • Targeted the correct branch (see PR Targeting)
  • Provided a link to the relevant issue or specification
  • Followed the guidelines for building SDK modules
  • Included the necessary unit and integration tests
  • Added a changelog entry to CHANGELOG.md
  • Included comments for documenting Go code
  • Updated the relevant documentation or specification
  • Reviewed "Files changed" and left comments if necessary
  • Confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed this PR does not introduce changes requiring state migrations, OR confirmed migration code has been added to consumer and/or provider modules
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage

@MSalopek
Copy link
Contributor

MSalopek commented Aug 7, 2023

Hey, thanks for rebasing and re-surfacing this issue!

We are evaluating how to proceed with this. I'm unsure if we should push for changes to ibc-go/testing.

Since legacy_ibc_testing contains shims that allow ICS to use ibc-go/testing we are forced to keep it for now. We may choose to rename it to something more sensible - because it is not legacy.

This ties into multiple aspects of testing in ICS, so we have to keep this in the repo (and working) for now.

There is a bigger testing refactor underway, this will also be included in the refactor.

Thanks again!

@tbruyelle
Copy link
Contributor Author

OK no problem @MSalopek I understand. Thanks for your response.

Just out of curiosity, what are the other shims you're talking about? The only one I know is the one that implies that tiny patch to ibc/testing , and so far when it's applied everything seems to work fine.

@MSalopek
Copy link
Contributor

MSalopek commented Aug 7, 2023

OK no problem @MSalopek I understand. Thanks for your response.

Just out of curiosity, what are the other shims you're talking about? The only one I know is the one that implies that tiny patch to ibc/testing , and so far when it's applied everything seems to work fine.

I see. I may be working with some outdated info on my part and all tests seem to pass with your changes and IBC fork. Apologies for that!

Any chance we can actually override the problematic function in ICS instead of making changes to ibc-go? I'm asking because I can't tell how long until something gets into an ibc-go release.

// QueryConsensusStateProof performs an abci query for a consensus state
// stored on the given clientID. The proof and consensusHeight are returned.
func (chain *TestChain) QueryConsensusStateProof(clientID string) ([]byte, clienttypes.Height) {
	clientState := chain.GetClientState(clientID)

Can't we just inherit from TestChain and override the func in ICS to solve this problem?

Does that seem feasible?

Btw thanks for the great work!

@tbruyelle
Copy link
Contributor Author

From what I tried initially, that didn't seem feasible, but I can have a second look.

On the other hand, we can ask the IBC team to see if this is something they can integrate quickly. The last time I ran the tests on their repo, the patch hadn't break anything.

@MSalopek
Copy link
Contributor

MSalopek commented Aug 8, 2023

From what I tried initially, that didn't seem feasible, but I can have a second look.

On the other hand, we can ask the IBC team to see if this is something they can integrate quickly. The last time I ran the tests on their repo, the patch hadn't break anything.

I'll get back to you with that one. We'll need to wait for a release though, but that's not a big problem.

@MSalopek
Copy link
Contributor

MSalopek commented Aug 8, 2023

@tbruyelle Can you open a PR to ibc-go with changes you suggested and implemented on a fork and link it here?

I can help elaborating with why changes are required.

@tbruyelle
Copy link
Contributor Author

@MSalopek Great, I opened a PR here cosmos/ibc-go#4315 🙏

@tbruyelle tbruyelle force-pushed the chore/remove-legacy-ibc-testing-rebased branch from b38ba53 to 14bb349 Compare August 30, 2023 13:08
@github-actions github-actions bot added C:Testing Assigned automatically by the PR labeler C:x/provider Assigned automatically by the PR labeler C:x/types Assigned automatically by the PR labeler labels Aug 30, 2023
@tbruyelle
Copy link
Contributor Author

@MSalopek I rebased again on master and applied the cosmos/ibc-go patch that should be shipped in 7.2.1. Everything runs fine on my machine, but the CI complains about e2e test fail. Can you rerun the job (I don't have that permission), that sounds flaky. Thx!

@tbruyelle
Copy link
Contributor Author

@MSalopek Good news, ibc-go 7.2.1 has been released, and it contains the fix required to make the tests pass in this PR.

As a result all tests are green, I remove the draft status and it is ready to review and merge \o/.

@tbruyelle tbruyelle marked this pull request as ready for review September 1, 2023 09:09
@tbruyelle tbruyelle requested a review from a team as a code owner September 1, 2023 09:09
@tbruyelle tbruyelle force-pushed the chore/remove-legacy-ibc-testing-rebased branch from 014f057 to cdb43f9 Compare September 5, 2023 08:47
@MSalopek
Copy link
Contributor

MSalopek commented Sep 5, 2023

Awesome! I'll review this and progress with the changes.

Thank you very much!

@tbruyelle
Copy link
Contributor Author

I've rebased on main so now the ibc-go version is 7.3.0, but it still contains the required fix.

Copy link
Contributor

@shaspitz shaspitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great overall and I really support this work! Just some small comments

tests/integration/common.go Show resolved Hide resolved
tests/integration/common.go Show resolved Hide resolved
tests/integration/common.go Outdated Show resolved Hide resolved
tests/integration/setup.go Show resolved Hide resolved
tests/integration/throttle.go Show resolved Hide resolved
Copy link
Contributor

@shaspitz shaspitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved!

Copy link
Contributor

@MSalopek MSalopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for these changes and for following up with changes in ibc-go.

Approve!

@mpoke mpoke merged commit 4f9d35a into cosmos:main Sep 7, 2023
@tbruyelle tbruyelle deleted the chore/remove-legacy-ibc-testing-rebased branch September 11, 2023 13:15
shaspitz added a commit that referenced this pull request Sep 20, 2023
* build(deps): bump actions/checkout from 3 to 4 (#1257)

Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps)!: bump github.com/cosmos/ibc-go/v7 from 7.2.0 to 7.3.0 (#1258)

* build(deps): bump github.com/cosmos/ibc-go/v7 from 7.2.0 to 7.3.0

Bumps [github.com/cosmos/ibc-go/v7](https://github.com/cosmos/ibc-go) from 7.2.0 to 7.3.0.
- [Release notes](https://github.com/cosmos/ibc-go/releases)
- [Changelog](https://github.com/cosmos/ibc-go/blob/main/CHANGELOG.md)
- [Commits](cosmos/ibc-go@v7.2.0...v7.3.0)

---
updated-dependencies:
- dependency-name: github.com/cosmos/ibc-go/v7
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* add changelog entries

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: mpoke <[email protected]>

* build(deps): bump github.com/cosmos/cosmos-sdk from 0.47.4 to 0.47.5 (#1259)

* build(deps): bump github.com/cosmos/cosmos-sdk from 0.47.3 to 0.47.5

Bumps [github.com/cosmos/cosmos-sdk](https://github.com/cosmos/cosmos-sdk) from 0.47.3 to 0.47.5.
- [Release notes](https://github.com/cosmos/cosmos-sdk/releases)
- [Changelog](https://github.com/cosmos/cosmos-sdk/blob/main/CHANGELOG.md)
- [Commits](cosmos/cosmos-sdk@v0.47.3...v0.47.5)

---
updated-dependencies:
- dependency-name: github.com/cosmos/cosmos-sdk
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* add changelog entries

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: mpoke <[email protected]>

* chore: Separate semver (#1217)

separate semver

* docs: cleanup changelog (#1260)

fix changelog

* fix!: validate MsgTransfer before calling Transfer() (#1244)

* validate MsgTransfer

* add TestSendRewardsToProvider

* update DefaultConsumerUnbondingPeriod to 14 days

* update changelog

* fix linter

* fix test

* apply review suggestions

* update changelog

* docs: Create adr-012-separate-releasing.md (#1229)

* Create adr-011-separate-releasing.md

* Update docs/docs/adrs/adr-011-separate-releasing.md

Co-authored-by: Philip Offtermatt <[email protected]>

* adr 12 not 11

* correct that we use postfix not prefix

* explanation on example release flow

---------

Co-authored-by: Philip Offtermatt <[email protected]>

* fix: remove addr validation for provider fee pool addr param (#1262)

* fix: remove validation for provider chain address since we cannot validate it properly on consumer

* add changelog entry

* docs: update CHANGELOG.md for `v3.2.0-consumer` release (#1268)

* Update CHANGELOG.md

* Update CHANGELOG.md

* chore: remove legacy_ibc_testing (rebased on main) (#1185)

* chore: remove legacy_ibc_testing

* fix import

* introduce provider.UnmarshalConsumerPacketData

* use patched ibc-go

* fix annoying import order

* test: ignore key ordering

Seems like ibctesting.GenerateKeys can returns keys in different orders
when test cover is enabled.

* fix after rebase

* replace allinbits/ibc-go with patched cosmos/ibc-go

Also fix panic in TestRedelegationNoConsumer

* fix lint

* use released ibc-go 7.3.0

* add newPacketFromConsumer/Provider helper funcs

* constructPacket method return ccv type instead of []byte

* tests: increase timeout in nightly e2e for multiconsumer (#1272)

* test: Add light client attack to e2e tests (#1249)

* Add light client attack to e2e tests

* Add details about the attack types

* Rename validatorAddress to validatorPrivateKeyAddress

* Add URL to CometMock to flag

* Improve wording for light client attack run

* Add submitting equivocation proposals and change consu->consumerName

* build(deps): bump google.golang.org/grpc from 1.57.0 to 1.58.0 (#1284)

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.57.0 to 1.58.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.57.0...v1.58.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ci: update mergify and dependabot for v2.x-lsm (#1281)

update mergify and dependabot for v2.x-lsm

* build(deps): bump github.com/oxyno-zeta/gomock-extra-matcher from 1.1.0 to 1.2.0 (#1286)

build(deps): bump github.com/oxyno-zeta/gomock-extra-matcher

Bumps [github.com/oxyno-zeta/gomock-extra-matcher](https://github.com/oxyno-zeta/gomock-extra-matcher) from 1.1.0 to 1.2.0.
- [Release notes](https://github.com/oxyno-zeta/gomock-extra-matcher/releases)
- [Changelog](https://github.com/oxyno-zeta/gomock-extra-matcher/blob/master/release.config.js)
- [Commits](oxyno-zeta/gomock-extra-matcher@v1.1.0...v1.2.0)

---
updated-dependencies:
- dependency-name: github.com/oxyno-zeta/gomock-extra-matcher
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat!: provider proposal for changing reward denoms (#1280)

* new provider prop type

* add methods and tests for new prop, update docs

* remove old tx, fix tests

* e2e handling

* fix command type

* boilerplate

* fix e2e tests

* Update CHANGELOG.md

* lint

* validate denoms

* Update proposal.go

* rm msg string

* fix tests

* rm chain in change denom action

* lint

* test for invalid denom

* events for both add and remove

* Update proposal_test.go

* docs: introduce ADR on slashing on the provider chain (#1252)

* initial draft of the adr

* small change on intro.md to avoid huge diff

* clean up

* take into account Marius' comments

* rewrite v0.47 Cosmos SDK link because it was returning 404 and redirecting

* more cleaning up

* update based on comments

* removed confusing sentence on voting power

* add missing ADRs in the intro file

* add tokens to power conversion

* add paragraph on key pruning and references to light-client attacks code

* Update template title

* Took into account comments.

* augment pseudocode to skip redelegation/undelegation entries

* fix identation issue

---------

Co-authored-by: Karolos Antoniadis <[email protected]>

* ci: update mergify and dependabot for v3.2.x-consumer (#1297)

* update ymls

* add newline

---------

Co-authored-by: mpoke <[email protected]>

* ci: update bots for v2.1.x-provider-lsm (#1305)

update bots for v2.1.x-provider-lsm

* Fix `build` in makefile (#1303)

fix build in makefile

* refactor: Vaguely named consumer structs (#1288)

* Rename GenesisState proto
* make proto-gen
* proto rename: Params -> ConsumerParams
* make proto-gen
* App, fix type change for Param renaming
* App, fix type change for GenesisState renaming
* Fix unit-tests for GenesisState renaming
* Fix unit-tests for Params renaming
* Addressed review comments
* Fix linter issues

* build(deps): bump google.golang.org/grpc from 1.58.0 to 1.58.1 (#1306)

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.58.0 to 1.58.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.58.0...v1.58.1)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat: increment consensus ver and register migration (#1295)

* increment consensus ver and register migration

* Update CHANGELOG.md

* Update migration.go

* Update module.go

* tests: Export struct fields in the e2e tests (#1313)

* Make struct fields in e2e exported

* Un-capitalize binary name

* Remove prop type

* Channel to channel in comments

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: mpoke <[email protected]>
Co-authored-by: Philip Offtermatt <[email protected]>
Co-authored-by: Dmitry Kolupaev <[email protected]>
Co-authored-by: Thomas Bruyelle <[email protected]>
Co-authored-by: MSalopek <[email protected]>
Co-authored-by: insumity <[email protected]>
Co-authored-by: Karolos Antoniadis <[email protected]>
Co-authored-by: Simon Noetzlin <[email protected]>
Co-authored-by: bernd-m <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:Testing Assigned automatically by the PR labeler C:x/provider Assigned automatically by the PR labeler C:x/types Assigned automatically by the PR labeler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor or remove ibc_legacy_testing from ICS
4 participants